﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="SolicitarTaxi.aspx.cs" Inherits="SITAX.SolicitarTaxi" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 97px;
        }

        .auto-style7 {
            width: 108px;
        }
        .auto-style8 {
            width: 131px;
        }
        .auto-style5 {
            width: 134px;
        }
        .auto-style9 {
            width: 120px;
        }
        .auto-style10 {
            width: 138px;
        }
        </style>
    <script src="Scripts/jquery-1.4.1-vsdoc.js"></script>
    <script src="Scripts/jquery-1.4.1.js"></script>
    <script src="Scripts/jquery-1.4.1.min.js"></script>

    <script>
        var ban = true;

        function BuscarServicio() {
            email = document.getElementById('<%=Label13.ClientID%>');
            //alert(email.innerText);

            var parametro = { Email: "'" + email.innerText.toString() + "'" };
            $.ajax({
                type: "GET",
                url: "/SolicitarTaxi.aspx/GetSolicitud",
                data: parametro,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                success: function (result) {
                    //alert(JSON.stringify(result.d));
                    var Icontrol = (typeof result.d) == 'string' ? eval('(' + result.d + ')') : result.d;
                    //alert((Icontrol.respuesta));
                    if ((ban == true) && (Icontrol.respuesta.length>0)) {
                        if (Icontrol.respuesta == '1') {
                            alert("Servicio asignado con el codigo 2344");
                            ban = false;
                            BorrarSolicitud(Icontrol);
                        } else {
                            if (Icontrol.respuesta == '0') {
                                alert("Servicio no Disponible");
                                ban = false;
                                BorrarSolicitud(Icontrol);
                            }
                        }
                    }

                    //$("#dtCliente").html('');
                    //$.each(lClientes, function (index, item) {
                    //    $("#dtCliente").append(item.nombre + " " + item.cedula + "<br/>");
                    //});
                },
                error: function (jqXHR, status, error) {
                    alert(error + "-" + jqXHR.responseText);
                }
            });


        }

        function BorrarSolicitud(con) {
            var parametro = { email: "'" + con.pasajero.Email.toString() + "'", placa: "'" + con.taxi.Placa.toString() + "'" };
            $.ajax({
                type: "GET",
                url: "/SolicitarTaxi.aspx/BorrarSolicitud",
                data: parametro,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                success: function (result) {
                    //alert(JSON.stringify(result.d));
                    var Icontrol = (typeof result.d) == 'string' ? eval('(' + result.d + ')') : result.d;
                },
                error: function (jqXHR, status, error) {
                    alert(error + "-" + jqXHR.responseText);
                }
            });
        }

        setInterval(BuscarServicio,3000)
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   
    <asp:Label ID="Label1" runat="server"></asp:Label>
   
    <br />
    <br />
    <table style="width: 26%;">
        <tr>
            <td class="auto-style10">
                <asp:Button ID="BtMapa" runat="server" OnClick="Button2_Click" Text="Mapa" />
            </td>
            <td>
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Editar Perfil" />
            </td>
        </tr>
    </table>
    <br />
    <br />
    <asp:Label ID="Label12" runat="server" Text="DATOS DEL CONDUCTOR"></asp:Label>
    <br />
    <table style="width: 68%;">
        <tr>
            <td class="auto-style7">
                <asp:Label ID="Label5" runat="server" Text="Email: "></asp:Label>
            </td>
            <td class="auto-style1">
                <asp:TextBox ID="TxEmail" runat="server"></asp:TextBox>
            </td>
            <td class="auto-style8">
                <asp:Label ID="Label6" runat="server" Text="Telefono: "></asp:Label>
            </td>
            <td class="auto-style5">
                <asp:TextBox ID="TxTelefono" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style7">
                <asp:Label ID="Label2" runat="server" Text="Primer Nombre:"></asp:Label>
            </td>
            <td class="auto-style1">
                <asp:TextBox ID="TxNombre" runat="server"></asp:TextBox>
            </td>
            <td class="auto-style8">
                <asp:Label ID="Label7" runat="server" Text="Primer Apellido:"></asp:Label>
            </td>
            <td class="auto-style5">
                <asp:TextBox ID="TxApellido" runat="server"></asp:TextBox>
            </td>
        </tr>
        </table>
       
    <br />
    DATOS DEL TAXI<br />
    <table style="width: 29%;">
        <tr>
            <td class="auto-style9">PLACA:</td>
            <td>
                <asp:TextBox ID="Txtplaca" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style9">MARCA</td>
            <td>
                <asp:TextBox ID="Txtmarca" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>
       
    <br />
                <asp:Button ID="btnSolicitar" runat="server" Text="Solicitar Taxi" OnClick="btnSolicitar_Click" />
                   
    <br />
    <asp:Label ID="Label13" runat="server"></asp:Label>
                   
</asp:Content>
 
